#ifndef __PORTABLE_H__
#define __PORTABLE_H__

/**
 *  This file is part of PennerBot
 *
 *  Copyright (C) 2010 microkernel
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <ctime>
#include <cstdlib>

#include <core/random.hpp>

#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif

inline void PortableMicroSleep(unsigned int msec)
{
#ifdef _WIN32
    Sleep(msec);
#else
    usleep(msec*1000);
#endif
}

inline void PortableSleep(unsigned int sec)
{
#ifdef _WIN32
    Sleep(sec*1000);
#else
    sleep(sec);
#endif
}

inline void PortableSleep(unsigned int lowsec, unsigned int highsec)
{
    PBot::Core::Random rnd;
    int sec = rnd(lowsec, highsec);

#ifdef _WIN32
    Sleep(sec*1000);
#else
    sleep(sec);
#endif
}

#endif // __PORTABLE_H__
